package com.lingyun.financialmanagement.controller;

import com.lingyun.financialmanagement.dao.pojo.ComponentPart;
import com.lingyun.financialmanagement.dao.pojo.Users;
import com.lingyun.financialmanagement.service.AdminService;
import com.lingyun.financialmanagement.service.BusinessTripService;
import com.lingyun.financialmanagement.service.ComponentPartService;
import com.lingyun.financialmanagement.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    @Autowired
    private ComponentPartService componentPartService;

    @Autowired
    private BusinessTripService businessTripService;

    // ~~~~~~~~~~~~用户~~~~~~~~~~~~~~~
    // 增加用户
    @PostMapping("addUser")
    public Result addUser(@RequestBody Users user){
        return adminService.addUser(user);
    }

    // 修改用户密码、权限（后面可能增加修改用户是否停用）
    @PostMapping("updateUser")
    public Result updateUser(@RequestBody Users user){
        return adminService.updateUser(user);
    }

    // 查询所有用户
    @GetMapping("selectAllUser")
    public Result selectAllUser(){
        return adminService.selectAllUser();
    }

    // ~~~~~~~~~~~~元器件~~~~~~~~~~~~~~~
    // 元器件 赊销划账
    @PostMapping("updatePaymentMethod")
    public Result updatePaymentMethod(@RequestBody ComponentPart componentPart){
        return componentPartService.updatePaymentMethod(componentPart);
    }

    // 元器件  赊销总金额
    @GetMapping("selectComponentPartCreditCost")
    public Result selectComponentPartCreditCost(){
        return componentPartService.selectComponentPartCreditCost();
    }

    // 元器件  所有待审核删除元器件
    @GetMapping("selectCheckPending")
    public Result selectCheckPending(){
        return componentPartService.selectCheckPending();
    }

    // 元器件  所有待审核删除元器件  同意 与 否
    @PostMapping("updateCheckPending")
    public Result updateCheckPending(@RequestParam Integer id, @RequestParam String state){
        return componentPartService.updateCheckPending(id, state);
    }

}
